package com.rongxun.hbwallet.mvp.presenter;

import android.support.annotation.NonNull;

import com.rongxun.base.BasePresenter;
import com.rongxun.base.ResponseSubscriber;
import com.rongxun.hbwallet.model.bean.CandyTask;
import com.rongxun.hbwallet.model.bean.Notice;
import com.rongxun.hbwallet.mvp.contract.IHome;

import java.util.List;

/**
 * 创建者     庄丰泽
 * 创建时间   2018/5/18 13:42
 * 描述   首页
 */

public class HomePresenter extends BasePresenter<IHome.IView, IHome.IModel> implements IHome.IPresenter {

    public HomePresenter(@NonNull IHome.IView pUi) {
        super(pUi);

    }

    public HomePresenter(@NonNull IHome.IView pUi, @NonNull IHome.IModel pModel) {
        super(pUi, pModel);
    }

    @Override
    public void getNotice(String language) {
        addSubscribe(getModel()
                .getNotice(language)
                .subscribeWith(new ResponseSubscriber<Notice>(getView()) {
                    @Override
                    public void onSuccess(Notice notice) {
                        List<Notice.NoticeBean> notice1 = notice.getNotice();
                        getView().showNotice(notice1);
                    }

                    @Override
                    public void disposeEorCode(String message, String code) {

                    }
                }));
    }

    @Override
    public void getCandyTask() {
        addSubscribe(getModel()
                .getCandyTask()
                .subscribeWith(new ResponseSubscriber<List<CandyTask>>(getView()) {
                    @Override
                    public void onSuccess(List<CandyTask> candyTasks) {
                        getView().showCandyTask(candyTasks);
                    }

                    @Override
                    public void disposeEorCode(String message, String code) {

                    }
                }));
    }
}
